<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="initial-scale=1, maximum=1,minimum=1, user-scalable=no" />
        <title>注册</title>
        <!-- Bootstrap -->
        <link href="__PUBLIC__/h-ui/yuyue/bootstrap/css/bootstrap.min.css" rel="stylesheet">
        <link href="__PUBLIC__/h-ui/yuyue/css/base.css" rel="stylesheet">
    </head>
    <body style="background-color: #fff;">
        <div class="logo"><img src="__PUBLIC__/h-ui/yuyue/images/test/logo.jpg" /></div>
        <div class="container-fluid">            
            <div class="ui-form register">
                <div class="form-item">
                    <input type="text" class="width" name="phone" id="phone" placeholder="请输入手机号" />
                </div>  
                <div class="form-item">
                    <input type="text" class="width" name="nickname" id="nickname" placeholder="请输入姓名" />
                </div>  
                <div class="form-item">
                    <input type="text" class="width" name="card" id="card" placeholder="请输入身份证" />
                </div>
                <div class="form-item">
                    <input type="password" class="width" name="pwds" id="pwds" placeholder="请输入密码" />
                </div>          
                <div class="form-item code clearfix">
                    <input placeholder="请输入验证码" type="text" id="code" name="code" />
                    <button type="button" class="btn btn-code pull-right">获取验证码</button>
                </div>
                <div class="form-item" style="margin-top: 50px;">
                    <button class="btn btn-ok" style="padding: 11px 20px;">确定</button>
                </div>               
            </div>
        </div>
    </body>
    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script type="text/javascript" src="__PUBLIC__/h-ui/lib/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/h-ui/lib/layer/2.4/layer.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
            //获取验证码
            $(".btn-code").on('click', function(){
                var phone = $("#phone").val();
                if(phone.length <= 0){
                    layer.msg('请输入手机号码', {icon: 5, time: 2000});
                    return false;
                }
                //发送请求
                $.get('getcode.html', {phone: phone}, function(row){
                    if(row/1 == 1){
                        layer.msg('验证码发送成功', {icon: 1, time: 2000});
                    }else if(row/1 == 2){
                        layer.msg('验证码在15分钟内有效', {icon: 1, time: 2000});
                    }else{
                        layer.msg('验证码发送失败', {icon: 2, time: 2000});
                    }
                });
            });

            //提交数据
            $(".btn-ok").on('click', function(){
                var fromData = {};
                var phone = $("#phone").val();
                if(phone.length <= 0){
                    layer.msg('请输入手机号码', {icon: 5, time: 2000});
                    return false;
                }else{
                    fromData.phone = phone;
                }

                var nickname = $("#nickname").val();
                if(nickname.length <= 0){
                    layer.msg('请输入姓名', {icon: 5, time: 2000});
                    return false;
                }else{
                    fromData.nickname = nickname;
                }

                var card = $("#card").val();
                if(card.length <= 0){
                    layer.msg('请输入身份证号', {icon: 5, time: 2000});
                    return false;
                }else{
                    fromData.card = card;
                }

                var pwds = $("#pwds").val();
                if(pwds.length <= 0){
                    layer.msg('请输入密码', {icon: 5, time: 2000});
                    return false;
                }else{
                    fromData.pwds = pwds;
                }

                var code = $("#code").val();
                if(code.length <= 0){
                    layer.msg('请输入验证码', {icon: 5, time: 2000});
                    return false;
                }else{
                    fromData.code = code;
                }

                $.post('register.html', fromData, function(row){
                    if(row/1 == 1){
                        location.href = '/xj/yuyue/index.html';
                    }else if(row/1 == 2){
                        layer.msg('您已注册');
                    }else{
                        layer.msg('注册失败', {icon: 2, time: 2000});
                    }
                });
            });
        });
    </script>
</html>
